
package com.ktgj.common.core.utils.helper;

import com.ktgj.common.core.utils.xml.XElement;
import com.ktgj.common.core.utils.xml.XmlHelp;

import java.util.List;

public class XmlHelper
{

	public static <T> T XmlDeserialize(String xmlFile, Class<?> clazz)
	{
		XElement e = XElement.load(xmlFile);
		return XmlHelp.getData(e, clazz);
	}

	public static <T> T XmlDeserializeString(String xmlString, Class<?> clazz)
	{
		XElement e = XElement.loadXml(xmlString);
		return XmlHelp.getData(e, clazz);
	}

	public static <T> List<T> XmlDeserializeList(String xml, Class<?> clazz)
	{
		XElement e = XElement.loadXml(xml);
		return XmlHelp.getData(e, clazz);
	}

	public static <T> void XmlSerialize(T data, String xmlFile)
	{
		XmlFileHelp<T> helper = new XmlFileHelp<T>(xmlFile, "");
		helper.saveData(data);
	}
}
